<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            border: 2px solid #000;
            /* 清除浮动：方法1 */
            /* overflow: hidden; */
            /* 清除浮动 方法2   不推荐*/
            /* clear: both; */
        }

        /* 清除浮动 方法3 最佳实践*/
        .clearfix::after {
            content: "";
            display: block;
            clear: both;
        }

        p {
            width: 100px;
            height: 100px;
            background-color: khaki;
            /* float: left; */
            margin-right: 10px;
        }
    </style>
</head>

<body>
    <div class="clearfix">
        <p>

        </p>
        <p>

        </p>
    </div>
    <div class="clearfix">
        <p></p>
        <p></p>
    </div>
</body>

</html>